-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
update nestjs peer dependencies to v10 #518
Conversation
@liaoliaots could you have a look on this? |
@mahsumurebe it looks like we also need to upgrade node.js required version to 16 based on NestJS Migration Guide |
Actually, it looks like !518 is actually more acurate beacause it does update everything needed and introduces major update to package |
I’ve already changed the nodejs required version. Please check this |
Hi @liaoliaots Can you check the pull request? |
Hey @liaoliaots , can you take a look here? |
Looking forward to this one, it's blocking us from upgrading to v10 |
How is the state of this ? |
any update? I need this upgrade |
@Beni312 The repo owner is not making updates, I've removed import { Injectable, Logger, OnModuleDestroy } from '@nestjs/common';
import { Redis } from 'ioredis';
import { RedisException } from './redis.exception';
@Injectable()
export class RedisService implements OnModuleDestroy {
private client: Redis | undefined; // undefined bc it might not exist due to lazy connect
private createClient() {
this.client = new Redis({
host: process.env.REDIS_HOST,
port: Number(process.env.REDIS_PORT),
password: process.env.REDIS_PASSWORD,
retryStrategy: (times: number) => {
if (times > 10) {
return undefined;
}
// retry at longer intervals based on the number of retries so far, max 3 seconds
return Math.min(times * 100, 3000);
},
});
if (!this.client) {
throw new RedisException('Could not connect to Redis');
}
this.client.on('error', (error) => {
Logger.error(`Redis error: ${error}`);
});
return this.client;
}
getClient(): Redis {
if (!this.client) {
this.createClient(); // lazy connect
}
return this.client;
}
async onModuleDestroy() {
if (this.client) {
return new Promise((resolve, reject) => {
this.client?.quit((err, reply) => {
if (err) {
return reject(err);
}
resolve(reply);
});
});
}
}
} ...usable like so import { RedisService } from 'src/redis/redis.service';
export class YourClass {
constructor(
private readonly redisService: RedisService,
) {
// ...
}
}
async yourFunction() {
const redis = this.redisService.getClient();
await redis.set(
// see ioredis documentation for basic usage
);
} Hope that helps. |
I put it in my application, works well, thanks :) |
Please check out the new version: version 10 of @liaoliaots/nestjs-redis. |
PR Type
Update peer dependencies of
@nestjs
to the latest version (v10).What is the current behavior?
NestJS recently released version 10 approximately two weeks ago, resulting in our project encountering the following warning:
Issue Number: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Other information